package com.san.common.task;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.PersistJobDataAfterExecution;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.san.metadata.service.OperationMetadataService;

/**
 * 操作元数据执行任务
 * 
 * @author xiangyz
 *
 */
@PersistJobDataAfterExecution
@DisallowConcurrentExecution
public class OperationMetadataJob implements Job {
	
	private static final Logger logger = LoggerFactory.getLogger(OperationMetadataJob.class);
	
	@Autowired
	OperationMetadataService operationService;

	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {

		JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
		if (null != jobDataMap) {
			Long operationId = jobDataMap.getLong("operationId");
			if (null != operationId && operationId.longValue() > 0) {
				logger.info(operationId + "_执行开始...");
				
				operationService.runOperationJob(operationId);

				logger.info(operationId + "_执行结束...");
			}
		}
	}


}
